<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>充值/提现</title>
    <style>
        :root {
            --primary-color: #165DFF;
            --secondary-color: #4080FF;
            --accent-color: #FF7D00;
            --text-color: #333333;
            --light-text: #666666;
            --bg-color: #F5F7FA;
            --card-bg: #FFFFFF;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            --border-radius: 12px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', sans-serif;
        }

        body {
            background-color: var(--bg-color);
            background-image: 
                radial-gradient(circle at 25% 25%, rgba(22, 93, 255, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 75% 75%, rgba(22, 93, 255, 0.03) 0%, transparent 50%);
            background-attachment: fixed;
            min-height: 100vh;
            color: var(--text-color);
        }

        .header {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            padding: 20px 40px;
            background: rgba(255, 255, 255, 0.8);
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            z-index: 10;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 24px;
            font-weight: 700;
            color: var(--primary-color);
            display: flex;
            align-items: center;
        }

        .logo i {
            margin-right: 10px;
            color: var(--accent-color);
        }

        .button {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: var(--border-radius);
            cursor: pointer;
            text-decoration: none;
            transition: all 0.3s ease;
            margin-right: 15px;
            display: inline-flex;
            align-items: center;
        }

        .button:hover {
            background-color: var(--secondary-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(22, 93, 255, 0.2);
        }

        .button i {
            margin-right: 5px;
        }

        .logout-button {
            background-color: #FF0000;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: var(--border-radius);
            cursor: pointer;
            text-decoration: none;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
        }

        .logout-button:hover {
            background-color: #CC0000;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(204, 0, 0, 0.2);
        }

        .logout-button i {
            margin-right: 5px;
        }

        .nav-buttons {
            display: flex;
            align-items: center;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 120px 40px 40px;
        }

        .form-container {
            background: var(--card-bg);
            border-radius: var(--border-radius);
            box-shadow: 0 8px 30px rgba(22, 93, 255, 0.15);
            padding: 30px;
            transition: all 0.3s ease;
            border: 1px solid rgba(22, 93, 255, 0.1);
            position: relative;
            overflow: hidden;
        }

        .form-container::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 6px;
            background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
        }

        .form-container:hover {
            transform: translateY(-8px);
            box-shadow: 0 12px 40px rgba(22, 93, 255, 0.2);
        }

        .form-title {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 30px;
            color: var(--primary-color);
        }

        .toggle-buttons {
            margin-bottom: 20px;
        }

        .toggle-buttons button {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: var(--border-radius);
            cursor: pointer;
            transition: all 0.3s ease;
            margin-right: 10px;
        }

        .toggle-buttons button:hover {
            background-color: var(--secondary-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(22, 93, 255, 0.2);
        }

        .input-group {
            margin-bottom: 20px;
        }

        .input-group label {
            display: block;
            margin-bottom: 5px;
            color: var(--light-text);
        }

        .input-group select,
        .input-group input[type="number"],
        .input-group input[type="password"] {
            width: 100%;
            padding: 10px 15px;
            border: 1px solid #E0E3E9;
            border-radius: var(--border-radius);
            font-size: 16px;
            transition: all 0.3s ease;
        }

        .input-group select:focus,
        .input-group input[type="number"]:focus,
        .input-group input[type="password"]:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.2);
        }

        .submit-button {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: var(--border-radius);
            cursor: pointer;
            text-decoration: none;
            font-size: 16px;
            transition: all 0.3s ease;
        }

        .submit-button:hover {
            background-color: var(--secondary-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(22, 93, 255, 0.2);
        }

        .footer {
            text-align: center;
            padding: 20px;
            color: var(--light-text);
            font-size: 14px;
            margin-top: 60px;
        }
    </style>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
    <!-- 顶部导航 -->
    <div class="header">
        <div class="logo">
            <i class="fa fa-bank"></i>
            安心银行
        </div>
        <div class="nav-buttons">
            <a href="/personal" class="button">
                <i class="fa fa-user-circle"></i> 个人中心
            </a>
            <a href="/" class="logout-button">
                <i class="fa fa-sign-out"></i> 退出登录
            </a>
        </div>
    </div>

    <!-- 主要内容 -->
    <div class="container">
        <div class="form-container">
            <h1 class="form-title">充值/提现</h1>
            <form action="/savemoney" method="post">
                <!-- 切换按钮 -->
                <div class="toggle-buttons">
                    <button type="button" onclick="showTopup()">充值</button>
                    <button type="button" onclick="showWithdrawal()">提现</button>
                </div>

                <!-- 充值区域 -->
                <div id="Topup" style="display: block;">
                    <div class="input-group">
                        <label>卡号充值</label>
                        <label>选择您要为哪张卡充值</label>
                        <select id="usercard">
                            {% for card in user.card_info %}
                                <option value="{{ card.cardID }}">{{ card.cardID }}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>

                <!-- 提现区域 -->
                <div id="Withdrawal" style="display: none;">
                    <div class="input-group">
                        <label>卡号提现</label>
                        <label>选择您要使用哪张卡提现</label>
                        <select id="withdrawalCard">
                            {% for card in user.card_info %}
                                <option value="{{ card.cardID }}">{{ card.cardID }}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>
                
                <!-- 添加隐藏字段 -->
                <input type="hidden" id="operation_type" name="operation_type">
                <input type="hidden" id="selected_card" name="selected_card">
                <div class="input-group">
                    <input type="number" name="money" placeholder="请输入金额：">
                </div>
                <div class="input-group">
                    <input type="password" name="password" placeholder="请输入密码：">
                </div>
                <input type="submit" class="submit-button" value="确认">
            </form>
        </div>
    </div>

    <!-- 页脚 -->
    <div class="footer">
        © 2025 安心银行 
    </div>

    <script>
        // 页面加载时默认显示充值，并设置 operation_type
        window.onload = function() {
            showTopup(); // 默认选中充值
        }

        // 显示“充值”区域，隐藏“提现”区域
        function showTopup() {
            document.getElementById("Topup").style.display = "block";
            document.getElementById("Withdrawal").style.display = "none";
            // 设置操作类型为“充值”
            document.getElementById("operation_type").value = "recharge";
        }

        // 显示“提现”区域，隐藏“充值”区域
        function showWithdrawal() {
            document.getElementById("Withdrawal").style.display = "block";
            document.getElementById("Topup").style.display = "none";
            // 设置操作类型为“提现”
            document.getElementById("operation_type").value = "withdraw";
        }

        // 监听选择框变化，更新隐藏字段
        document.addEventListener('DOMContentLoaded', function() {
            const selectElements = document.querySelectorAll('#usercard, #withdrawalCard');
            const hiddenField = document.getElementById('selected_card');

            selectElements.forEach(select => {
                select.addEventListener('change', function() {
                    hiddenField.value = this.value;
                    console.log('已选择卡:', this.value);
                });

                // 初始化隐藏字段
                if (hiddenField.value === '') {
                    hiddenField.value = select.value;
                }
            });
        });
    </script>
</body>
</html>